<?php


namespace app\controller\v1;


use app\model\Advertising;
use app\model\SpecialType;
use think\facade\Db;
use think\Request;

/**
 * 文章，公告等
 * Class Article
 * @package app\controller\v1
 */
class Article
{


    /**
     * 轮播图
     * @param Advertising $advertising
     * @param Request $request
     * @return Advertising[]|array|\think\Collection
     */
    public function Banner(Advertising $advertising, Request $request)
    {
        return $advertising->banner($request->only(['type']));
    }

    /**
     * 专区分类
     * @param SpecialType $specialType
     * @param Request $request
     * @return mixed
     */
    public function SpecialType(SpecialType $specialType, Request $request)
    {
        return $specialType->type($request->only(['type']));
    }


    /**
     * 热门搜索
     */
    public function HotSearch(\app\model\Article $Article)
    {
        return $Article->hot();
    }

    public function suggest(Request $request, \app\model\Article $Article)
    {
        return $Article->suggest($request->data);
    }


    /**
     * App版本信息
     * @param Request $request
     * @return \think\Response|\think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * created by Shy at 2021/6/9 15:38
     */
    public function App(Request $request)
    {
        $DB = Db::name('renew')
            ->where(['type' => $request->param('type')])
            ->find();
        return app('json')->json_success('成功', $DB);
    }
}